<!DOCTYPE html>
<html lang="si">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="description" content="මෙම අත්හදා බැලීම කුඩා ෂේක්ස්පියර් දත්ත කට්ටලය මත පදනම් වූ රේඛීය අගතීන් (අලිබී) සමඟ අවධානය යොමු කරයි."/>

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:image:src" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta name="twitter:title" content="රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු කරන්න"/>
    <meta name="twitter:description" content="මෙම අත්හදා බැලීම කුඩා ෂේක්ස්පියර් දත්ත කට්ටලය මත පදනම් වූ රේඛීය අගතීන් (අලිබී) සමඟ අවධානය යොමු කරයි."/>
    <meta name="twitter:site" content="@labmlai"/>
    <meta name="twitter:creator" content="@labmlai"/>

    <meta property="og:url" content="https://nn.labml.ai/transformers/alibi/experiment.html"/>
    <meta property="og:title" content="රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු කරන්න"/>
    <meta property="og:image" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta property="og:site_name" content="රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු කරන්න"/>
    <meta property="og:type" content="object"/>
    <meta property="og:title" content="රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු කරන්න"/>
    <meta property="og:description" content="මෙම අත්හදා බැලීම කුඩා ෂේක්ස්පියර් දත්ත කට්ටලය මත පදනම් වූ රේඛීය අගතීන් (අලිබී) සමඟ අවධානය යොමු කරයි."/>

    <title>රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු කරන්න</title>
    <link rel="shortcut icon" href="/icon.png"/>
    <link rel="stylesheet" href="../../pylit.css?v=1">
    <link rel="canonical" href="https://nn.labml.ai/transformers/alibi/experiment.html"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css" integrity="sha384-zTROYFVGOfTw7JV7KUu8udsvW2fx4lWOsCEDqhBreBwlHI4ioVRtmIvEThzJHGET" crossorigin="anonymous">

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-4V3HC8HBLH"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-4V3HC8HBLH');
    </script>
</head>
<body>
<div id='container'>
    <div id="background"></div>
    <div class='section'>
        <div class='docs'>
            <p>
                <a class="parent" href="/">home</a>
                <a class="parent" href="../index.html">transformers</a>
                <a class="parent" href="index.html">alibi</a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations" target="_blank">
                    <img alt="Github"
                         src="https://img.shields.io/github/stars/labmlai/annotated_deep_learning_paper_implementations?style=social"
                         style="max-width:100%;"/></a>
                <a href="https://twitter.com/labmlai" rel="nofollow" target="_blank">
                    <img alt="Twitter"
                         src="https://img.shields.io/twitter/follow/labmlai?style=social"
                         style="max-width:100%;"/></a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations/tree/master/labml_nn/transformers/alibi/experiment.py" target="_blank">
                    View code on Github</a>
            </p>
        </div>
    </div>
    <div class='section' id='section-0'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-0'>#</a>
            </div>
            <h1><a href="index.html">රේඛීය පක්ෂග්රාහී (අලිබී) අත්හදා බැලීම සමඟ අවධානය යොමු</a> කරන්න</h1>
<p>මෙය <a href="index.html">අලිබී ආකෘතියක්</a>පුහුණු කිරීම සඳහා කරන ලද පයිටෝච් අත්හදා බැලීමකි. </p>
<p>මෙය <a href="../gpt/index.html">අපගේ GPT ආකෘතිය</a>මත පදනම් වේ. </p>
<p><a href="https://app.labml.ai/run/1454f9ba044a11ed8364e5e321a405ac"><img alt="View Run" src="https://img.shields.io/badge/labml-experiment-brightgreen"></a></p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">16</span><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="lineno">17</span><span class="kn">from</span> <span class="nn">torch.utils.data</span> <span class="kn">import</span> <span class="n">DataLoader</span>
<span class="lineno">18</span>
<span class="lineno">19</span><span class="kn">from</span> <span class="nn">labml</span> <span class="kn">import</span> <span class="n">experiment</span><span class="p">,</span> <span class="n">tracker</span>
<span class="lineno">20</span><span class="kn">from</span> <span class="nn">labml.configs</span> <span class="kn">import</span> <span class="n">option</span><span class="p">,</span> <span class="n">calculate</span>
<span class="lineno">21</span><span class="kn">from</span> <span class="nn">labml_helpers.datasets.text</span> <span class="kn">import</span> <span class="n">SequentialUnBatchedDataset</span>
<span class="lineno">22</span><span class="kn">from</span> <span class="nn">labml_nn.transformers.alibi</span> <span class="kn">import</span> <span class="n">AlibiMultiHeadAttention</span>
<span class="lineno">23</span><span class="kn">from</span> <span class="nn">labml_nn.experiments.nlp_autoregression</span> <span class="kn">import</span> <span class="n">transpose_batch</span>
<span class="lineno">24</span><span class="kn">from</span> <span class="nn">labml_nn.transformers</span> <span class="kn">import</span> <span class="n">TransformerConfigs</span>
<span class="lineno">25</span><span class="kn">from</span> <span class="nn">labml_nn.transformers.gpt</span> <span class="kn">import</span> <span class="n">Configs</span> <span class="k">as</span> <span class="n">GPTConfigs</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-1'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-1'>#</a>
            </div>
            <h2>වින්යාසකිරීම්</h2>
<p>අපි <a href="../gpt/index.html">GPT වින්යාසයන්</a> දීර් extend කර අවධානය යොමු කිරීමේ යාන්ත්රණය වෙනස් කරමු. </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">28</span><span class="k">class</span> <span class="nc">Configs</span><span class="p">(</span><span class="n">GPTConfigs</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-2'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-2'>#</a>
            </div>
            <p>අලිබීපදනම් කරගත් ට්රාන්ස්ෆෝමර් (පහත අර්ථ දක්වා ඇත) </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">36</span>    <span class="n">transformer</span><span class="p">:</span> <span class="n">TransformerConfigs</span> <span class="o">=</span> <span class="s1">&#39;GPT_ALiBi&#39;</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-3'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-3'>#</a>
            </div>
            <p>දිගුවලංගු කිරීමේ කට්ටලය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">38</span>    <span class="n">valid_seq_len</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">128</span>
<span class="lineno">39</span>    <span class="n">valid_loader</span> <span class="o">=</span> <span class="s1">&#39;shuffled_longer_valid_loader&#39;</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-4'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-4'>#</a>
            </div>
            <p> ආරම්භකහා අවසාන ටෝකන වලදී පාඩු ලොග් කරන්න</p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">41</span>    <span class="k">def</span> <span class="nf">other_metrics</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-5'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-5'>#</a>
            </div>
            <p>පුහුණුඅනුක්රමයේ දිග (වලංගු කිරීමේදී) වැඩි ටෝකන තිබේ නම්, </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">46</span>        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">seq_len</span> <span class="o">&lt;</span> <span class="n">output</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-6'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-6'>#</a>
            </div>
            <p>පුහුණුඅනුක්රමයේ දිග දී අලාභය ලොග් කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">48</span>            <span class="n">tracker</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;loss.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seq_len</span> <span class="o">-</span> <span class="mi">1</span><span class="si">}</span><span class="s1">.&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">loss_func</span><span class="p">(</span><span class="n">output</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">seq_len</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">target</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">seq_len</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]))</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-7'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-7'>#</a>
            </div>
            <p>පළමුටෝකනයේ අලාභය ලොග් කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">50</span>            <span class="n">tracker</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;loss.0.&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">loss_func</span><span class="p">(</span><span class="n">output</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">target</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-8'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-8'>#</a>
            </div>
            <p>අවසානටෝකනයේ අලාභය ලොග් කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">52</span>        <span class="n">tracker</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;loss.</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">output</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="si">}</span><span class="s1">.&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">loss_func</span><span class="p">(</span><span class="n">output</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">target</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-9'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-9'>#</a>
            </div>
            <p> අලිබීඅවධානය මොඩියුලයක් සාදන්න</p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">55</span><span class="k">def</span> <span class="nf">_alibi_mha</span><span class="p">(</span><span class="n">c</span><span class="p">:</span> <span class="n">TransformerConfigs</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-10'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-10'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">59</span>    <span class="k">return</span> <span class="n">AlibiMultiHeadAttention</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">n_heads</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">d_model</span><span class="p">,</span> <span class="n">dropout_prob</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">dropout</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-11'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-11'>#</a>
            </div>
            <p>සියළුමඅවධානය යොමු කිරීමේ යාන්ත්රණ අලිබී වෙත සකසන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">63</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">encoder_attn</span><span class="p">,</span> <span class="s1">&#39;alibi_mha&#39;</span><span class="p">,</span> <span class="n">_alibi_mha</span><span class="p">)</span>
<span class="lineno">64</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">decoder_attn</span><span class="p">,</span> <span class="s1">&#39;alibi_mha&#39;</span><span class="p">,</span> <span class="n">_alibi_mha</span><span class="p">)</span>
<span class="lineno">65</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">decoder_mem_attn</span><span class="p">,</span> <span class="s1">&#39;alibi_mha&#39;</span><span class="p">,</span> <span class="n">_alibi_mha</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-12'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-12'>#</a>
            </div>
            <p> <code  class="highlight"><span></span><span class="n">valid_seq_len</span></code>
 අනුක්රමික දිග සහිත වලංගුකරණ දත්ත පැටවුම මාරු කර ඇත</p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">68</span><span class="nd">@option</span><span class="p">(</span><span class="n">Configs</span><span class="o">.</span><span class="n">valid_loader</span><span class="p">)</span>
<span class="lineno">69</span><span class="k">def</span> <span class="nf">shuffled_longer_valid_loader</span><span class="p">(</span><span class="n">c</span><span class="p">:</span> <span class="n">Configs</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-13'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-13'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">73</span>    <span class="k">return</span> <span class="n">DataLoader</span><span class="p">(</span><span class="n">SequentialUnBatchedDataset</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">valid</span><span class="p">,</span>
<span class="lineno">74</span>                                                 <span class="n">dataset</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">text</span><span class="p">,</span>
<span class="lineno">75</span>                                                 <span class="n">seq_len</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">valid_seq_len</span><span class="p">),</span>
<span class="lineno">76</span>                      <span class="n">batch_size</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">batch_size</span><span class="p">,</span>
<span class="lineno">77</span>                      <span class="n">collate_fn</span><span class="o">=</span><span class="n">transpose_batch</span><span class="p">,</span>
<span class="lineno">78</span>                      <span class="n">shuffle</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-14'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-14'>#</a>
            </div>
            <h3>අලිබීපදනම් කරගත් ට්රාන්ස්ෆෝමර් වින්යාසයන්</h3>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">81</span><span class="nd">@option</span><span class="p">(</span><span class="n">Configs</span><span class="o">.</span><span class="n">transformer</span><span class="p">,</span> <span class="s1">&#39;GPT_ALiBi&#39;</span><span class="p">)</span>
<span class="lineno">82</span><span class="k">def</span> <span class="nf">_transformer_configs</span><span class="p">(</span><span class="n">c</span><span class="p">:</span> <span class="n">Configs</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-15'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-15'>#</a>
            </div>
            <p>අපගේ <a href="../configs.html#TransformerConfigs">වින්යාසගත කළ හැකි ට්රාන්ස්ෆෝමර් ක්රියාත්මක කිරීම</a> භාවිතා කරමු </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">89</span>    <span class="n">conf</span> <span class="o">=</span> <span class="n">TransformerConfigs</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-16'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-16'>#</a>
            </div>
            <p>කාවැද්දීම්සහ පිවිසුම් උත්පාදනය සඳහා වචන මාලාව ප්රමාණ සකසන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">91</span>    <span class="n">conf</span><span class="o">.</span><span class="n">n_src_vocab</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">n_tokens</span>
<span class="lineno">92</span>    <span class="n">conf</span><span class="o">.</span><span class="n">n_tgt_vocab</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">n_tokens</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-17'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-17'>#</a>
            </div>
            <p>GPTස්ථානගත නැණවත් පෝෂණය සඳහා GELU සක්රිය කිරීම භාවිතා කරයි </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">94</span>    <span class="n">conf</span><span class="o">.</span><span class="n">ffn</span><span class="o">.</span><span class="n">activation</span> <span class="o">=</span> <span class="s1">&#39;GELU&#39;</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-18'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-18'>#</a>
            </div>
            <p>AliBiස්ථානීය කාවැද්දීම් භාවිතා නොකරයි </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">97</span>    <span class="n">conf</span><span class="o">.</span><span class="n">src_embed</span> <span class="o">=</span> <span class="s1">&#39;no_pos&#39;</span>
<span class="lineno">98</span>    <span class="n">conf</span><span class="o">.</span><span class="n">tgt_embed</span> <span class="o">=</span> <span class="s1">&#39;no_pos&#39;</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-19'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-19'>#</a>
            </div>
            <p>සියළුමඅවධානය යොමු කිරීමේ යාන්ත්රණ අලිබී වෙත සකසන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">101</span>    <span class="n">conf</span><span class="o">.</span><span class="n">encoder_attn</span> <span class="o">=</span> <span class="s1">&#39;alibi_mha&#39;</span>
<span class="lineno">102</span>    <span class="n">conf</span><span class="o">.</span><span class="n">decoder_attn</span> <span class="o">=</span> <span class="s1">&#39;alibi_mha&#39;</span>
<span class="lineno">103</span>    <span class="n">conf</span><span class="o">.</span><span class="n">decoder_mem_attn</span> <span class="o">=</span> <span class="s1">&#39;alibi_mha&#39;</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-20'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-20'>#</a>
            </div>
            <p> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">106</span>    <span class="k">return</span> <span class="n">conf</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-21'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-21'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">109</span><span class="k">def</span> <span class="nf">main</span><span class="p">():</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-22'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-22'>#</a>
            </div>
            <p>අත්හදාබැලීම සාදන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">111</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;gpt_alibi&quot;</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-23'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-23'>#</a>
            </div>
            <p>වින්යාසසාදන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">113</span>    <span class="n">conf</span> <span class="o">=</span> <span class="n">Configs</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-24'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-24'>#</a>
            </div>
            <p>වින්යාසයන්අභිබවා යන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">115</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">configs</span><span class="p">(</span><span class="n">conf</span><span class="p">,</span> <span class="p">{</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-25'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-25'>#</a>
            </div>
            <p>අක්ෂරමට්ටමේ ටෝකනයිසර් භාවිතා කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">117</span>        <span class="s1">&#39;tokenizer&#39;</span><span class="p">:</span> <span class="s1">&#39;character&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-26'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-26'>#</a>
            </div>
            <p>කඩිනම්බෙදුම්කරු හිස් ය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">119</span>        <span class="s1">&#39;prompt_separator&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-27'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-27'>#</a>
            </div>
            <p>නියැදීමසඳහා විමසුමක් ආරම්භ කිරීම </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">121</span>        <span class="s1">&#39;prompt&#39;</span><span class="p">:</span> <span class="s1">&#39;It is &#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-28'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-28'>#</a>
            </div>
            <p>කුඩාෂේක්ස්පියර් දත්ත කට්ටලය භාවිතා කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">123</span>        <span class="s1">&#39;text&#39;</span><span class="p">:</span> <span class="s1">&#39;tiny_shakespeare&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-29'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-29'>#</a>
            </div>
            <p>'text ':' ටිනි_ෂේක්ස්පියර්_නො_බෙදීම් ', </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre></pre></div>
        </div>
    </div>
    <div class='section' id='section-30'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-30'>#</a>
            </div>
            <p>කසන්දර්භය ප්රමාණය භාවිතා <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord coloredeq eqa" style=""><span class="mord" style="">128</span></span></span></span></span></span> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">127</span>        <span class="s1">&#39;seq_len&#39;</span><span class="p">:</span> <span class="mi">64</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-31'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-31'>#</a>
            </div>
            <p>කසන්දර්භය ප්රමාණය භාවිතා <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord coloredeq eqa" style=""><span class="mord" style="">128</span></span></span></span></span></span> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">129</span>        <span class="s1">&#39;valid_seq_len&#39;</span><span class="p">:</span> <span class="mi">80</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-32'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-32'>#</a>
            </div>
            <p><span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">32</span></span></span></span></span> Epochs සඳහා දුම්රිය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">131</span>        <span class="s1">&#39;epochs&#39;</span><span class="p">:</span> <span class="mi">128</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-33'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-33'>#</a>
            </div>
            <p>කණ්ඩායම්ප්රමාණය <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord coloredeq eqa" style=""><span class="mord" style="">128</span></span></span></span></span></span> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">133</span>        <span class="s1">&#39;batch_size&#39;</span><span class="p">:</span> <span class="mi">128</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-34'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-34'>#</a>
            </div>
            <p>එක් <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">10</span></span></span></span></span> යුගයකට වරක් පුහුණුව සහ වලංගු කිරීම අතර මාරු වන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">136</span>        <span class="s1">&#39;inner_iterations&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-35'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-35'>#</a>
            </div>
            <p>ට්රාන්ස්ෆෝමර්වින්යාසයන් </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">139</span>        <span class="s1">&#39;transformer.d_model&#39;</span><span class="p">:</span> <span class="mi">128</span><span class="p">,</span>
<span class="lineno">140</span>        <span class="s1">&#39;transformer.ffn.d_ff&#39;</span><span class="p">:</span> <span class="mi">512</span><span class="p">,</span>
<span class="lineno">141</span>        <span class="s1">&#39;transformer.n_heads&#39;</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span>
<span class="lineno">142</span>        <span class="s1">&#39;transformer.n_layers&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="lineno">143</span>        <span class="s1">&#39;transformer.dropout&#39;</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span>
<span class="lineno">144</span>    <span class="p">})</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-36'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-36'>#</a>
            </div>
            <p>ඉතිරිකිරීම සහ පැටවීම සඳහා ආකෘති සකසන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">147</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">add_pytorch_models</span><span class="p">({</span><span class="s1">&#39;model&#39;</span><span class="p">:</span> <span class="n">conf</span><span class="o">.</span><span class="n">model</span><span class="p">})</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-37'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-37'>#</a>
            </div>
            <p>අත්හදාබැලීම ආරම්භ කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">150</span>    <span class="k">with</span> <span class="n">experiment</span><span class="o">.</span><span class="n">start</span><span class="p">():</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-38'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-38'>#</a>
            </div>
            <p>පුහුණුධාවනය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">152</span>        <span class="n">conf</span><span class="o">.</span><span class="n">run</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-39'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-39'>#</a>
            </div>
            <p> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">156</span><span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="lineno">157</span>    <span class="n">main</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='footer'>
        <a href="https://papers.labml.ai">Trending Research Papers</a>
        <a href="https://labml.ai">labml.ai</a>
    </div>
</div>
<script src=../../interactive.js?v=1"></script>
<script>
    function handleImages() {
        var images = document.querySelectorAll('p>img')

        for (var i = 0; i < images.length; ++i) {
            handleImage(images[i])
        }
    }

    function handleImage(img) {
        img.parentElement.style.textAlign = 'center'

        var modal = document.createElement('div')
        modal.id = 'modal'

        var modalContent = document.createElement('div')
        modal.appendChild(modalContent)

        var modalImage = document.createElement('img')
        modalContent.appendChild(modalImage)

        var span = document.createElement('span')
        span.classList.add('close')
        span.textContent = 'x'
        modal.appendChild(span)

        img.onclick = function () {
            console.log('clicked')
            document.body.appendChild(modal)
            modalImage.src = img.src
        }

        span.onclick = function () {
            document.body.removeChild(modal)
        }
    }

    handleImages()
</script>
</body>
</html>